package com.junxian.demo02.controller;

import com.junxian.demo02.exception.MyException;
import com.junxian.demo02.exception.MyException01;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by admin on 2018/12/3.
 */
@Controller
public class HelloWorldController {

    @RequestMapping("/hello")
    public String hello() throws Exception {
        throw new Exception("发生错误！");
    }

    @RequestMapping("/json")
    public String json() throws Exception {
        throw new MyException("成功了哎！");
    }

    @RequestMapping("/jsontest")
    public String jsonTest() throws Exception {
        throw new MyException01("test json！");
    }

    @RequestMapping("/")
    public String index(ModelMap map) {
        map.addAttribute("host" , "http://www.baidu.com");
        return "index";
    }
}

